📒 学海无涯 · 更新于 2026-05-30 22:34
2026-05-30-idempotent
#english
#每日一学
📖 每日一学 · 2026-05-30(周六·技术词汇)
🔤 idempotent /ˌaɪdɛmˈpoʊtənt/
📝 释义:
- 幂等的(数学/计算机术语:同一操作执行多次,结果与执行一次相同)
- 亦指”等幂的”
💬 例句:
“Make sure your API endpoint is idempotent — if the user accidentally clicks submit twice, the order shouldn’t be created twice.” “确保你的 API 端点是幂等的——如果用户不小心点了两次提交,订单不应该被创建两次。”
🧠 记忆技巧:
- 词根拆解:拉丁语 idem(相同)+ potent(力量、效能)→ “相同的力量”→ 不管执行几次,效果都一样
- 联想:
PUT请求 vsPOST请求——PUT 天然幂等,POST 不是。下次写 REST API 时想想这个词!
💡 拓展:
- 幂等操作:
DELETE /user/123是幂等的(删一次和删十次结果一样);POST /orders不是幂等的(每次调用都创建新订单) - 常见搭配:idempotent operation(幂等操作)、idempotent key(幂等键)、idempotent function(幂等函数)
- 数学来源:在代数中,idempotent 指满足 $x^2 = x$ 的元素,例如 0 和 1 都是幂等的(0×0=0, 1×1=1)
- 相关词汇:commutative(交换律)、associative(结合律)、deterministic(确定性的)